package com.example.demo.HelloWorld;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

@RestController
public class HelloWorldController {
    @RequestMapping("/test_spring")
    public List<Integer> helloworld() {
        return fib3(5150);
    }

    private static List<Integer> fib3(int n) {
        List<Integer> libSeq = new LinkedList<Integer>();

        if (n < 1) {
            return libSeq;
        }
        libSeq.add(1);
        libSeq.add(1);
        if (n <= 2) {
            return libSeq;
        }

        for (int x = 0; x < n - 2; x = x + 1) {
            // int size = libSeq.size();
            // System.out.println(size);
            // Integer a = libSeq.get(libSeq.size() - 1);
            // Integer b = libSeq.get(libSeq.size() - 2);
            libSeq.add(libSeq.get(libSeq.size() - 1) + libSeq.get(libSeq.size() - 2));
        }
        // List<Integer> res = libSeq.subList(0, 200);
        return libSeq.subList(0, 200);
    }
}
